<?php
/**
 * Zead
 *
 * LICENSE	
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.opensource.org/licenses/bsd-license.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to eu@marcelomx.com so we can send you a copy immediately.
 *
 * @category   Zead
 * @author     Marcelo Rodrigues Gonzaga <eu@marcelomx.com>
 * @copyright  Copyright (c) 2008 Marcelo Rodrigues Gonzaga
 * @link       http://code.google.com/p/zead 
 * @license    http://www.opensource.org/licenses/bsd-license.php     New BSD License
 *
 **/


/** @see Zead_Player_Plugin_Abstract **/
require_once 'Zead/Player/Plugin/Abstract.php';

/**
 * @category   Zead
 * @package    Zead_Player
 * @package    Zead_Player_Plugin
 * @copyright  Copyright (c) 2008 Marcelo Rodrigues Gonzaga 
 * @license    http://www.opensource.org/licenses/bsd-license.php     New BSD License 
 */
abstract class Zead_Player_Plugin_Abstract 
{
	/** @var Zend_Controller_Request_Abstract **/
	protected $_request  = null;

	/** @var Zend_Controller_Response_Abstract **/
	protected $_response = null;

	/** @var Zead_Player **/
	protected $_player = null;

	/**
	 * Retorna o objeto REQUEST
	 * @return Zend_Controller_Request_Abstract
	 */	
	public function getRequest() 
	{
		return $this->_request;
	}

	/**
	 * Seta o objeto REQUEST
	 * 
	 * @param  Zend_Controller_Request_Abstract $request
	 * @return Zead_Player_Plugin_Abstract
	 */
	public function setRequest(Zend_Controller_Request_Abstract $request) 
	{
		$this->_request = $request;
		return $this;
	}

	/**
	 * Retorna o objeto RESPONSE
	 * @return Zend_Controller_Response_Abstract
	 */
	public function getResponse() 
	{
		return $this->_response;
	}

	/**
	 * Seta o objeto RESPONSE (resposta)
	 * 
	 * @param  Zend_Controller_Response_Abstract $response
	 * @return Zead_Player_Dispatcher
	 */
	public function setResponse(Zend_Controller_Response_Abstract $response) 
	{
		$this->_response = $response;
		return $this;
	}

	/**
	 * Set the frontControlller
	 * 
	 * @param  Zead_Player $player
	 * @return Zead_Player_Plugin_Abstract
	 */
	public function setPlayer(Zead_Player $player)
	{
		$this->_player = $player;
		return $this;
	}

	/**
	 * Returns the frontController
	 * 
	 * @return Zead_Player
	 */
	public function getPlayer() 
	{
		if (null == $this->_player) {
			require_once 'Zead/Player.php';
			$this->setPlayer(Zead_Player::getInstance());
		}
		
		return $this->_player;
	}

	/**
	 * Execute the pre dispatch action before the main response process
	 * @return void
	 */
	public function preDispatch() 
	{
	}

	/**
	 * Execute the pre dispatch action after the main response process
	 * @return void
	 */
	public function postDispatch() 
	{
	}

	/**
	 * Return the current plugin name
	 * @return string
	 */
	public function getName() 
	{
		$name = get_class($this);
		if ($name == 'Zead_Player_Plugin_Abstract')
			throw new Zead_Player_Plugin_Exception('The plugin class needs extends '. $name);
			
		return array_pop(explode('_', $name));	
	}}

